using System;
using System.Security;
using Be.Timvw.Framework.Security;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Be.Timvw.Framework.Tests.Security.Principal.WindowsIdentityHelper
{
    [TestClass]
    public class WhenConstructing
    {
        [TestMethod]
        [ExpectedException(typeof(ArgumentException))]
        public void ShouldThrowIfLogonFails()
        {
            string username = LocalAccountInfo.InvalidUsername;
            string domain = Environment.MachineName;
            SecureString password = SecureStringHelper.Create(LocalAccountInfo.InvalidPassword);

            new Framework.Security.Principal.WindowsIdentityHelper(username, domain, password);
        }

        [TestMethod]
        public void ShouldNotThrowIfLogonSucceeds()
        {
            string username = LocalAccountInfo.ValidUsername;
            string domain = Environment.MachineName;
            SecureString password = SecureStringHelper.Create(LocalAccountInfo.ValidPassword);

            new Framework.Security.Principal.WindowsIdentityHelper(username, domain, password);
        }
    }
}